<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>

<form name="form1" id="form1" action="" method="post">
	<div class="pageMain">
		<div class="pageTitle"><%=MessageResourcesUtils.getMessage(request, "systemmanage.storemanagement.title") %><span></span><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storeuser.title") %><span></span><%=MessageResourcesUtils.getMessage(request, "dailyoperation.storeuser.useradd.title") %></div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i>*</i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %></label>
						<span>
							<input type="text" id="storecode" name="storecode" class="validate[required,maxSize[45]"/>
							<input type="hidden" id="storeid" name="storeid"  >
							<input type="hidden" id="website" name="website"  >
						</span>
					</li>
					<li>
						<i>&nbsp;&nbsp;</i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %></label>
						<span><input type="text" id="storename" name="storename" value="" readonly="readonly" /></span>
					</li>
				</ul>
				<ul>
					<li class="liw">
						<i>*</i>
						<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.userloginname") %></label>
						<span>
							<input type="text" id="loginname" name="loginname" class="validate[required,maxSize[15]">
							<span id="show_website"></span>
						</span>
					</li>
				</ul>
				<ul>
					<li>
						<i>*</i>
						<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.validstart") %></label>
						<span><input type="text" class="validate[required,custom[date]]" id="validstart" name="validstart" /></span>
					</li>
					<li>
						<i>*</i>
						<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.validend") %></label>
						<span><input type="text" class="validate[required,custom[date]]" id="validend" name="validend" /></span>
					</li>
				</ul>
				<ul>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.certsn") %></label>
						<span><input type="text" id="certsn" name="certsn" class="validate[maxSize[50]]" /></span>
					</li>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.certcn") %></label>
						<span><input type="text" id="certcn" name="certcn" class="validate[maxSize[50]]" /></span>
					</li>
				</ul>
			</div>			
        	<div class="button-group">
      			<input type="button" class="btn btn-default" id="butSave" name="butSave" value="<%=MessageResourcesUtils.getMessage(request, "common.button.save") %>" />
       			<input type="button" class="btn btn-default" id="butClean" name="butClean" value="<%=MessageResourcesUtils.getMessage(request, "common.button.clear") %>" />
       			<input type="button" class="btn btn-default" id="butReturn" name="butReturn" value="<%=MessageResourcesUtils.getMessage(request, "common.button.back") %>" />
			</div>
		</div>
	</div>
</form>

<script type="text/javascript">	
$(document).ready(function() {
	$('#validstart').date_input();
	$('#validend').date_input();
	
	$("#storecode").issNewMagnifier({
		title: '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.storemagnifiertitle") %>',
		url: '${systemctx}/publicMagnifier/publicMagnifier.json',
		sortName : 'modifytime',
		sortOrder : 'desc',
		linkName: 'number',
		callSqlKey: 'queryStoreMagnifierSql',
		changeIgnore: ['storecode'],
		columns: [[
				{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %>', field:'number', width:220, sortable:true, align: 'left', formel:'storecode'},
				{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %>', field:'name', width:300,sortable:true, align: 'left', formel:'storename'},
		       	{field:'website', hidden:true, formel:'website'},
		       	{field:'id', hidden:true, formel:'storeid'}
		]],
		onBeforeOpen:function(p){
	      var queryParams = {
    		  querystore: '%' + $("#storecode").val() + '%',
    		  statusid: <%=SysConstant.RecordStatus.VALID %>,
    		  state : <%=SysConstant.CommonApproveStatus.OK %>
	      };
	      return queryParams;
	    },
	    onClose : function() {
	    	var website = $("#website").val();
	    	$("#show_website").html("@"+website)
	    }
	});
	
	$('#butSave').click(function() {
		//获得所属省名称
		var exp = $('#form1').validationEngine('validate');
		var validstart = $('#validstart').val();
		var validend = $('#validend').val();
		validstart = validstart.replace(/\-/gi,"/");
		validend = validend.replace(/\-/gi,"/");
		var time1 = new Date(validstart).getTime();
		var time2 = new Date(validend).getTime();
		if(time1>=time2){
			alert("<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.date") %>");
			return;
		}
		if(exp==true){
			if($("#storeid").val() == '')
			{
				alert("<%=MessageResourcesUtils.getMessage(request, "systemmanage.user.storenotnull") %>");
				return;
			}
			// 显示进度条
			showSending();
			$.ajax({
				type: 'POST',
			    url: '${systemctx}/dailyoperation/storeuser/validattionAdminUser.json',
			    data: $("#form1").serialize(),
			    dataType: 'json',
			    success: function(data)
			    {
			    	//关闭执行...
					closeSending();
			    	if (data.messagetype == '2')
			    	{
			    		//显示AJAX请求后的提示信息
						$.fn.ajaxmessage(data);
			    	}
			    	else
			    	{
			    		form1.action="${systemctx}/dailyoperation/storeuser/addAdminUser.web";
						form1.submit();
			    	}
			    }
			});
		}
	});
	
	$('#butClean').click(function() {
		$('#loginname').val('');		
		$('#validstart').val('');		
		$('#validend').val('');		
		$('#certsn').val('');		
		$('#certcn').val('');		
	});
	
	$('#butReturn').click(function(){
		parent.document.location.reload();
	    $.fn.closeIssWindow();
	});
	
});
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>